package com.pachong.android.frameworkbase.utils;


import android.content.Context;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;

/**
 * property 工具类
 * 
 * @author Vivi Peng
 * 
 * @version 1.0.0
 * 
 * @date 2015-02-02
 */
public class PropertyHelper {
	

	/**
	 * 保证app运行的在有config数据的环境下
	 * 
	 * @param context
	 * @return
	 */
	public static Properties getProperties(Context context, File propertyFile) {
		Properties props = null;
		try {
			props = new Properties();
			InputStream in = new FileInputStream(propertyFile);
			props.load(in);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		return props;
	}


	public static void setProperties(Context context, File propertyFile, Properties p) {
		OutputStream fos;
		try {
			fos = new FileOutputStream(propertyFile);
			p.store(fos, null);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}



}
